//
//  PlayView.m
//  XMLY
//
//  Created by lanou on 15/11/5.
//  Copyright © 2015年 曾杰. All rights reserved.
//

#import "PlayView.h"
#import "UIImageView+WebCache.h"
@implementation PlayView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        _pictureView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_HEIGHT, SCREEN_HEIGHT)];
        _pictureView.image = [UIImage imageNamed:@"playList"];
        [self addSubview:_pictureView];
        
        self.backBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _backBtn.frame = CGRectMake(10, 35, 20, 20);
        [_backBtn setImage:[UIImage imageNamed:@"fanhui"] forState:(UIControlStateNormal)];
        [self addSubview:_backBtn];
    
       
         self.scrollLabel = [[UITextView alloc] initWithFrame:CGRectMake(50, 30, SCREEN_WIDTH - 100, 30)];
        self.scrollLabel.backgroundColor = [UIColor clearColor];
        self.scrollLabel.textAlignment = NSTextAlignmentCenter;
        _scrollLabel.font = [UIFont systemFontOfSize:16];
        [self addSubview:_scrollLabel];
        
        self.mainImageView = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2 - 100, 100, 200, 200)];
//        _mainImageView.backgroundColor = [UIColor blackColor];
        _mainImageView.layer.cornerRadius = 100;
        _mainImageView.layer.masksToBounds = YES;
        [self addSubview:_mainImageView];
        
        self.slider = [[UISlider alloc] initWithFrame:CGRectMake(50, SCREEN_HEIGHT * 2 / 3, SCREEN_WIDTH - 150, 30)];
        [_slider setThumbImage:[UIImage imageNamed:@"shutiao"] forState:(UIControlStateNormal)];
    
        [self addSubview:_slider];
        self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 100, SCREEN_HEIGHT * 2 / 3, 50, 30)];
        [self addSubview:_timeLabel];
        
        self.beforeBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _beforeBtn.frame = CGRectMake(30 , SCREEN_HEIGHT * 2 / 3 + 85, 50, 50);
        [_beforeBtn setImage:[UIImage imageNamed:@"shangyiqu"] forState:(UIControlStateNormal)];
        [self addSubview:_beforeBtn];
        
        self.playAndPause = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _playAndPause.frame = CGRectMake(SCREEN_WIDTH / 2 -40 , SCREEN_HEIGHT * 2 / 3 + 70, 80, 80);
        [_playAndPause setImage:[UIImage imageNamed:@"zanting"] forState:(UIControlStateNormal)];
        _playAndPause.selected = YES;
        [self addSubview:_playAndPause];
        
        self.nextBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _nextBtn.frame = CGRectMake(SCREEN_WIDTH - 80 ,SCREEN_HEIGHT * 2 / 3 + 85, 50, 50);
        [_nextBtn setImage:[UIImage imageNamed:@"xiayiqu"] forState:(UIControlStateNormal)];
        [self addSubview:_nextBtn];
        
        
    }
    return self;
}


+(CGFloat)stringWidth:(NSString *)str
{
    NSDictionary * dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:16] forKey:NSFontAttributeName];
    CGRect bounds = [str boundingRectWithSize:CGSizeMake(0, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dic context:nil];
    return bounds.size.width;
}

- (void)configureViewWithModel:(ChildListModel *)model{
    [_mainImageView sd_setImageWithURL:[NSURL URLWithString:model.coverMiddle]];
    _scrollLabel.text = model.title;
    _scrollLabel.textAlignment = NSTextAlignmentCenter;
}


    
    
   

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
